#ifndef __QUEUE_H__
#define __QUEUE_H__

#include "linkedlist.h"

namespace algo
{

template<typename T>
class Queue
{
public:
	Queue():m_capacity(50) {}
	Queue(int capacity):m_capacity(capacity) {}

	virtual bool enqueue(const T &val);
	virtual bool dequeue(T &val);

	virtual int size();
    virtual bool isEmpty();

private:
	LinkedList<T> m_linkedlist;
	int m_capacity;
	
};


template<typename T>
bool Queue<T>::enqueue(const T &val)
{
	if (m_linkedlist.size() > m_capacity)
	{
		return false;
	}

	m_linkedlist.add(val);

	return true;
}

template<typename T>
bool Queue<T>::dequeue(T &val)
{
	if (isEmpty())
	{
		return false;
	}
	val = m_linkedlist.getFirstNode()->val;
	m_linkedlist.removeFirst();

	return true;
}

template<typename T>
int Queue<T>::size()
{
	return m_linkedlist.size();
}

template<typename T>
bool Queue<T>::isEmpty()
{
	return m_linkedlist.isEmpty();
}

}	// namespace end

#endif